package com.bluestone.run;

import com.bluestone.BaseAction;
import com.bluestone.action.ActionFactory;
import com.bluestone.context.ActionContext;
import com.bluestone.context.IContext;
import com.bluestone.scripts.ActionScript;
import com.bluestone.util.Util;

public class ActionController extends BaseController {

	@Override
	boolean executeContext(IContext context) {
		boolean flag = false;
		ActionContext actionContext = (ActionContext)context;
		ActionScript action = actionContext.getAction();
		BaseAction baseAction = ActionFactory.createAction(action);
		if (!baseAction.isValid(context)) {
			actionContext.addExecuteLog("run action " + baseAction.toString() + "-->" + flag);
			return true;
		}
		flag = baseAction.execute(actionContext);
		actionContext.addExecuteLog("run action " + baseAction.toString() + "-->" + flag);
		if (!flag) {
			actionContext.addExecuteLog("run action " + baseAction.toString() + "-->" + flag);
			Util.error("run action " + baseAction.toString() + "-->" + flag);
		}
		return flag;		
	}



}
